<?php
session_start();
if(isset($_POST["zoek"])) {
include('printstyle.php');
$taal = $_SESSION['taal'];
require_once('pasmy/dbwaarden.php');
include('french.php');
?> 
<h2><div style="text-align: center"><?php echo $dbzoeken[$taal];?></div></h2>
<?php
echo "<br><br>";
$mysql_id = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($db, $mysql_id);

// invoegen einde

if($_POST["yy"] == "-----") { $waardb = "vnzvrn" . $_POST["jaar"]; } else {$waardb = "vnzvrn" . $_POST["yy"];}
if($_POST["yy1"] == "-----") { $waardb = "vnzvrn" . $_POST["jaar"]; } else {$waardb = "vnzvrn" . $_POST["yy1"];}
if($_POST["yy2"] == "-----") { $waardb = "vnzvrn" . $_POST["jaar"]; } else {$waardb = "vnzvrn" . $_POST["yy2"];}

$sql = "Select * from `$waardb`";
if(!empty($_POST["driver"])) {
	$_POST["driver"] = mysql_real_escape_string($_POST["driver"]);
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";}	
	$sql .= "$ver `driver` like  '%$_POST[driver]%'";
	$en = 1;	
	}

if($_POST["jj"] !="-----") {
	$datum = $_POST["yy"] . "-" . $_POST["mm"] . "-" . $_POST["jj"];
	
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";}
	$sql .= " $ver `datum` like '$datum'";
	$en = 1;	
	}
if($_POST["jj1"] != "-----") {
	$datum1 = $_POST["yy1"] . "-" . $_POST["mm1"] . "-" . $_POST["jj1"];
	$datum2 = $_POST["yy2"] . "-" . $_POST["mm2"] . "-" . $_POST["jj2"];
	
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";}
	$sql .= " $ver `datum` >= '$datum1' and `datum` <= '$datum2'";
	$en = 1;
	
	}
if(!empty($_POST["ref"])) {
	$_POST["ref"] = mysql_real_escape_string($_POST["ref"]);
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `ref` like '%$_POST[ref]%'";
	$en = 1;
	}
if(!empty($_POST["client"])) {
	$_POST["client"] = mysql_real_escape_string($_POST["client"]);
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `client` like '%$_POST[client]%'";
	$en = 1;
	}
if(!empty($_POST["expedi"])) {
	$_POST["expedi"] = mysql_real_escape_string($_POST["expedi"]);
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `expediteur` like '%$_POST[expedi]%'";
	$en = 1;
	}
if(!empty($_POST["laadplaats"])) {
	$_POST["laadplaats"] = mysql_real_escape_string($_POST["laadplaats"]);
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `laadplaats` like '%$_POST[laadplaats]%'";
	$en = 1;
	}


if(!empty($_POST["desti"])) {
	$_POST["desti"] = mysql_real_escape_string($_POST["desti"]);
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `bestemmeling` like '%$_POST[desti]%'";
	$en = 1;
	}
if(!empty($_POST["ville"])) {
	$_POST["ville"] = mysql_real_escape_string($_POST["ville"]);
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `plaats` like '%$_POST[ville]%'";
	$en = 1;
	}
if(!empty($_POST["colis"])) {
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `colis` = '$_POST[colis]'";
	$en = 1;
	}
if(!empty($_POST["pal"])) {
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `pal` = '$_POST[pal]'";
	$en = 1;
	}
if(!empty($_POST["mp"])) {
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `mp` like '%$_POST[mp]%'";
	$en = 1;
	}
if(!empty($_POST["poids"])) {
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `poids` = '$_POST[poids]'";
	$en = 1;
	}
if(!empty($_POST["prix"])) {
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `prijs` like '%$_POST[prix]%'";
	$en = 1;
	}
if(!empty($_POST["week"])) {
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `week` = '$_POST[week]'";
	$en = 1;
	}
$sql = $sql . " order by `datum`,`plaats`";
?>
<form action="massiefupdate.php" method="POST">
<table border="1" width="100%" align="center">
<tr>
<td class="delsaux2"><?php echo $datum[$taal];?></td>
<td class="delsaux2"><?php echo $referentie[$taal];?></td>
<td class="delsaux2">CMR</td>
<td class="delsaux2"><?php echo $klant[$taal];?></td>
<td class="delsaux2"><?php echo $verzender[$taal];?></td>
<td class="delsaux2"><?php echo $laplaats[$taal];?></td>
<td class="delsaux2"><?php echo $bestemmeling[$taal];?></td>
<td class="delsaux2"><?php echo $plaats[$taal];?></td>
<td class="delsaux2">Colis</td>
<td class="delsaux2"><?php echo $pals[$taal];?></td>
<td class="delsaux2"><?php echo $vloerm[$taal];?></td>
<td class="delsaux2"><?php echo $gewicht[$taal];?></td>
<td class="delsaux2"><?php echo $pprijs[$taal];?></td>
<td class="delsaux2">Gasoil</td>
<td class="delsaux2">Chauffeur</td>
<td class="delsaux2">Camion</td>

<!-- <td class="delsaux2"><?php echo $opmerkingen[$taal];?></td> -->
<?php
if(isset($_POST["remark"])) {
	echo "<td class='delsaux2'>$opmerkingen[$taal]</td>";
	}
/*if($_SESSION['login'] < "22") {
		 echo "<td class='delsaux2'>Update</td>";
}
if($_SESSION['login'] < "17") {
		 echo "<td class='delsaux2'>Delete</td>";
}*/
 
?>
</tr>

<?php
if($_SESSION['login'] == "0") {
echo "<b>sql = $sql<b></br><br />";	
}
$res = mysql_query($sql, $mysql_id);
/*if(empty($row[0])) { echo "<tr><td colspan='14'><br /><div style='text-align: center'>
<b>Aucun document ne correspond aux termes de recherche sp&eacute;cifi&eacute;s </b></div><br /></td></tr>";}*/
$dag = "0000-00-00";
while ($row = mysql_fetch_row($res)) {
	if($row[0] > $dag) {$nombre++;$dag = $row[0];}
	/*if ($nombre%2 == 1)
    $klasse = "#fdd4d4";
  else
    $klasse = "#a9dea0";*/
	
	$dagdatum = explode("-",$row[0]);
	$tota = $tota + $row[10];
	$totag = $totag + $row[17];
	if(empty($row[16])) {$row[16]="&nbsp;";}
	//$ref2[$row[14]]=array("row[0]","$row[2]","$row[3]","$row[4]","$row[5]","$row[6]","$row[7]","$row[8]","$row[9]","$row[10]","$row[11]","$row[12]","$row[13]","$row[15]","$row[16]");
	//echo "<input type='hidden' name='recording' value='$ref2($row[14])' />";
	echo "<td class = 'zones'><input type='text' name='dag' size='10' value='$dagdatum[2]-$dagdatum[1]-$dagdatum[0]'></td>";
	echo "<td class = 'zones'><input type='text' name='ref' size='15' value='$row[1]'></td>";
	echo "<td class = 'zones'><input type='text' name='cmr' size='20' value='$row[16]'></td>";
	echo "<td class = 'zones'><div style='text-align: center'><input type='text' name='klant' value='$row[2]' /></div></td>";
	echo "<td class = 'zones'><div style='text-align: center'><input type='text' name='afzender' value='$row[3]'></div></td>";
	echo "<td class = 'zones'><div style='text-align: center'><input type='text' name='laadplaats' value='$row[15]'></div></td>";
	echo "<td class = 'zones'><div style='text-align: center'><input type='text' name='bestemmeling' value='$row[4]'></div></td>";
	echo "<td class = 'zones'><div style='text-align: center'><input type='text' name='losplaats' value='$row[5]'></div></td>";
	echo "<td class = 'zones'><div style='text-align: center'><input type='text' name='colis' size='4' value='$row[6]'></div></td>";
	echo "<td class = 'zones'><div style='text-align: center'><input type='text' name='paletten' size='3' value='$row[7]'></div></td>";
	echo "<td class = 'zones'><div style='text-align: center'><input type='text' name='laadmeter' size='4' value='$row[8]'></div></td>";
	echo "<td class = 'zones'><div style='text-align: center'><input type='text' name='gewicht' size='5' value='$row[9]'></div></td>";
	echo "<td class = 'zones'><div style='text-align: center'><input type='text' name='prijs' size='8' value='$row[10]'></div></td>";
	echo "<td class = 'zones'><div style='text-align: center'><input type='text' name='gasoil' size='5' value='$row[17]'></div></td>";
	echo "<td class = 'zones'><div style='text-align: center'><input type='text' name='chauffeur' value='$row[12]'></div></td>";
	echo "<td class = 'zones'><div style='text-align: center'><input type='text' name='camion' size='10' value='$row[18]'></div></td>";
	if(isset($_POST["remark"])) {
	echo "<td class='zones'>$row[11]</td>";
	}
	echo "<td class = 'zones'><a href='massiefupdate.php?nr=$row[14]&jaren=$waardb' class = 'linkblue'>Update</a></td>";
	/*}
	if($_SESSION['login'] < "15") {
		echo "<td class = 'zones'><a href='deleten.php?nr=$row[14]&jaren=$waardb' class = 'linkred'>Delete</a></td>";
		
	}*/
	echo "</tr>";
	

}
mysql_free_result($res);
echo "<tr><td colspan='12'>&nbsp;</td><td class = 'delsaux'>$tota</td>";
echo "<td class = 'delsaux'>$totag</td><td colspan='5'>&nbsp;</td></tr>";
$glob = $tota + $totag;
echo "<tr><td colspan='12'>&nbsp;</td><td class = 'delsaux2' colspan='2'>$glob</td><td colspan='5'>&nbsp;</td></tr>";
echo "</table>";

}
?>
<br /><br />
<font size="5"><strong><a href="masszoeken.php" class="linkblue"><div style="text-align: center">Retour</div></a></strong></font>
<div style="text-align: center"><input type="submit" name="doen" value="doen" /></div>
</form>